<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./code/chapter/16_game.js"></script>
    <script src="./code/levels.js"></script>

    <link rel="stylesheet" href="./css/game.css">
</head>

<body>
    <script>
        async function runGame(plans, Display) {
            let lives = 3;
            for (let level = 0; level < plans.length && lives > 0;) {
                console.log(`Level ${level + 1}, lives: ${lives}`);
                let status = await runLevel(new Level(plans[level]),
                    Display);
                if (status == "won") level++;
                else lives--;
            }
            if (lives > 0) {
                console.log("You've won!");
            } else {
                console.log("Game over");
            }
        }
        runGame(GAME_LEVELS, DOMDisplay);
    </script>
</body>

</html>